//
//  YZMVisitorViewController.swift
//  YZMweibo
//
//  Created by Simon on 16/4/18.
//  Copyright © 2016年 Simon. All rights reserved.
//

import UIKit

class YZMVisitorViewController: UITableViewController {
    //判断是否登录
    var isLogin:Bool = YZMUserAccountTools.sharedTools.isLogin
    // 访客视图
    var visitorView: YZMVistorView?
    
    override func loadView() {
        // 通过三目运算符
        isLogin ? super.loadView() : setupVisitorView()
        
        }
    
    override func viewDidLoad() {
        super.viewDidLoad()
    }
    
    // MARK: -  监听事件
    @objc private func login(){
        let oauthVc = YZMOAuthController()
        presentViewController(UINavigationController(rootViewController: oauthVc), animated: true, completion: nil)
        
    }
    // MARK: - 导航栏相关设置
    private func setupNav(){
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "login")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "login")
        
    }
    
    // MARK: -  设置视图
    private func setupVisitorView(){
        setupNav()
        visitorView = YZMVistorView()
        visitorView?.visitorClosure = {
            self.login()
        }
        view = visitorView
    }


    
    
}
